import { Camera } from "./camera.js";
import { mat4 } from '../gl-matrix/index.js';

export class PerspectiveCamera extends Camera {
    constructor(fov = 90, aspect = 1, near = 0.1, far = 1000) {
        super();

        this.fov = fov * Math.PI / 180;
        this.near = near;
        this.far = far;
        this.aspect = aspect;

        this.updateProjectionMatrix();
    }

    updateProjectionMatrix() {
        mat4.perspective(this._projectionMatrix, this.fov, this.aspect, this.near, this.far);
        mat4.invert(this._projectionMatrixInverse, this._projectionMatrix);
    }
}